<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Signal,com.ejoysoft.wlanyz.business.SignalCountry,com.ejoysoft.wlanyz.business.SignalClassOneAc,com.ejoysoft.wlanyz.business.SignalClassTwoAc,com.ejoysoft.wlanyz.business.SignalofAP,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException,java.sql.*" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
     if(!globa.userSession.hasRight("20015"))
     throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
  
%>
<%
   
    //查询条件
     //查询条件
    int  Flag=Integer.parseInt(ParamUtil.getString(request,"Flag","0"));//获取页面标志
    String  strCity=ParamUtil.getString(request,"city","").trim();//获取城市名
    String  strCountry=ParamUtil.getString(request,"country","").trim();//获取区县名
    String  strClassOneAC=ParamUtil.getString(request,"classone","").trim();//获取一级热点名
    String  strClassTwoAC=ParamUtil.getString(request,"classtwo","").trim();//获取二级热点名
    //int intAllCount = ParamUtil.getInt(request,"intAllCount",0);//获取区县个数
    String timedegree = ParamUtil.getString(request,"timedegree","").trim();//获取时间粒度
    String strStartTime = ParamUtil.getString(request,"strStartTime","").trim();//获取开始时间
    String strEndTime = ParamUtil.getString(request,"strEndTime","").trim();//获取结束时间
    String exportContent = ParamUtil.getString(request,"exportContent","");
    int intCurPage = Integer.parseInt(ParamUtil.getString(request,"intCurPage","1"));//当前页
  
   // System.out.println("****************");
	//System.out.print(intCurPage);
    String tWhere="WHERE 1=1 ";
	
   if(Flag==1){
   if (!strCity.equals("")) {
		tWhere += " and strcity LIKE '%" + strCity + "%'";
	}
	     //初始化
    Signal  Signal0=null;
    Signal obj=new Signal(globa);
    //记录总数
	int intAllCount=obj.getCount(tWhere);	
	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<Signal> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
		if(exportContent.equals("allPage"))
		{
			 vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
	}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县个数,一级热点个数,AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getCountryNum() + ",";
		       strSb += vctObj.get(i).getacNumber() + ",";
		       strSb += vctObj.get(i).getapNumber() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio() + ",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		        strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName = "信号分布分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
}
else if(Flag==2)
{ 
if (!strCity.equals("")&&!strCountry.equals("")) {
		tWhere += " and strcity = '" + strCity + "' and strcountry = '"+strCountry+"' ";
	}
	else if(!strCity.equals("")&&strCountry.equals("")){
	tWhere += " and strcity ='"+ strCity + "'";
	}
   //初始化
    SignalCountry  SignalCountry0=null;
    SignalCountry obj=new SignalCountry(globa);
   //记录总数
	int intAllCount=obj.getCount(tWhere);	
	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<SignalCountry> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
  	
	//System.out.println("exportContent=="+exportContent);
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点数量,AP数量,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrCountry().replace("\n","") + ",";
		       strSb += vctObj.get(i).getacNumber()+ ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+"市的信号分布分析分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
       
}
else if(Flag==3)
{
  if(!strClassOneAC.equals("")) tWhere += " and classoneac LIKE '%"+strClassOneAC+"%' ";
   if (!strCity.equals("")&&!strCountry.equals("")) {
		tWhere += " and strcity = '" + strCity + "' and strcountry = '"+strCountry+"' ";
	}
	else if(!strCity.equals("")&&strCountry.equals("")){
	tWhere += " and strcity ='"+ strCity + "'";
	}
	else if(strCity.equals("")&&!strCountry.equals("")){
	tWhere += " and strcountry = '"+ strCountry + "'";
	}
//初始化
    SignalClassOneAc  SignalClassOneAc0=null;
    SignalClassOneAc obj=new SignalClassOneAc(globa);
    //记录总数
	int intAllCount=obj.getCount(tWhere);	
	
	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<SignalClassOneAc> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
		if(exportContent.equals("allPage"))
		{ 
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点,二级热点个数,AP数量,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrCountry().replace("\n","") + ",";
		       strSb += vctObj.get(i).getclassOneAC().replace("\n","") + ",";
		       strSb += vctObj.get(i).getacNumber()+ ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+"-"+strCountry+"的信号分布分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());   
}
else if(Flag==4)
{
if(!strClassTwoAC.equals("")) tWhere += " and classtwoac LIKE '%"+strClassTwoAC+"%' ";
   if (!strCity.equals("")&&!strCountry.equals("")) {
		tWhere += " and strcity = '" + strCity + "' and strcountry = '"+strCountry+"' and classoneac = '"+strClassOneAC+"' ";
	}
	else if(!strCity.equals("")&&strCountry.equals("")){
	tWhere += " and strcity ='"+ strCity + "'";
	}
	else if(strCity.equals("")&&!strCountry.equals("")){
	tWhere += " and strcountry = '"+ strCountry + "'";
	}
	
//初始化
    SignalClassTwoAc  SignalClassTwoAc0=null;
    SignalClassTwoAc obj=new SignalClassTwoAc(globa);
   //记录总数
	int intAllCount=obj.getCount(tWhere);	
	
	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<SignalClassTwoAc> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
		if(exportContent.equals("allPage"))
		{ 
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点,二级热点,AP数量,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrCountry().replace("\n","") + ",";
		       strSb += vctObj.get(i).getclassOneAC().replace("\n","") + ",";
		       strSb += vctObj.get(i).getclassTwoAC().replace("\n","") + ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+"-"+strCountry+"-"+"一级热点"+strClassOneAC+ "的信号分布分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
	    }
	    else if(Flag==5)
{
  tWhere += " and strcity = '" + strCity + "' and strcountry = '"+strCountry+"' and classoneac = '"+strClassOneAC+"' and  classtwoac = '"+strClassTwoAC+"' ";
	
 //初始化
    SignalofAP  SignalofAP0=null;
    SignalofAP obj=new SignalofAP(globa);
    Connection conn = null;
	//记录总数
	int intAllCount=obj.getCount(tWhere);	
	//当前页
   String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<SignalofAP> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
  
		if(exportContent.equals("allPage"))
		{ 
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点,二级热点,AP名称,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrCountry().replace("\n","") + ",";
		       strSb += vctObj.get(i).getclassOneAC().replace("\n","") + ",";
		       strSb += vctObj.get(i).getclassTwoAC().replace("\n","") + ",";
		       strSb += vctObj.get(i).getapName().replace("\n","") + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+"-"+strCountry+"-"+"二级热点"+strClassTwoAC+"AP的信号分布分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
	    }
	%>
<%@ include file="../include/jsp/footer.jsp"%>
